package com.kakarote.authorization.service;

import com.alibaba.fastjson.JSONObject;
import com.kakarote.authorization.entity.AdminUserStatusBO;
import com.kakarote.core.common.ApiExplain;
import com.kakarote.core.common.Result;
import com.kakarote.core.feign.admin.entity.AdminUserInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zhang
 * 向admin模块请求企业信息
 */
@Component
@FeignClient(name = "admin", contextId = "auth")
public interface AdminUserService {

    /**
     * 通过用户名查询用户
     *
     * @param username 用户名
     * @return 结果信息
     */
    @PostMapping(value = "/adminUser/findByUsername")
    Result<List<AdminUserInfo>> findByUsername(@RequestParam("username") String username);

    /**
     * 通过code查询用户
     *
     * @param code code
     */
    @PostMapping(value = "/adminSuite/findUserByCpCode")
    Result<List<AdminUserInfo>> findUserByCpCode(@RequestParam("code") String code, @RequestParam("loginType") Integer loginType);

    /**
     * 通过code查询用户
     *
     * @param code code
     */
    @PostMapping(value = "/adminFly/findUserByFlyCode")
    public Result<List<AdminUserInfo>> findUserByFlyCode(@RequestParam("code") String code, @RequestParam("appId") String appId);


    @PostMapping(value = "/adminDingtalk/findUserByDingtalkCode")
    @ApiExplain("校验钉钉,获取用户信息")
    public Result<List<AdminUserInfo>> findUserByDingtalkCode(@RequestParam("code") String code, @RequestParam(value = "corpId", required = false) String corpId, @RequestParam("loginType") Integer loginType);


    /**
     * 通过企业id和企业用户userid查询用户名
     *
     * @param data 公司id|用户id  公司id和用户id中间用|分隔
     * @return 结果信息
     */
    @PostMapping(value = "/adminUser/findByCorpIdAndWxUserId")
    Result<List<AdminUserInfo>> findByCorpIdAndWxUserId(@RequestParam("data") String data);

    /**
     * 通过用户ID查询所属角色
     *
     * @param userId 用户ID
     * @return data
     */
    @RequestMapping(value = "/adminUser/queryUserRoleIds")
    Result<List<Long>> queryUserRoleIds(@RequestParam("userId") Long userId);

    /**
     * 设置用户状态
     *
     * @param adminUserStatusBO:用户状态修改BO
     * @return com.kakarote.core.common.Result
     */
    @PostMapping("/adminUser/setUserStatus")
    @ApiOperation("禁用启用")
    Result setUserStatus(@RequestBody AdminUserStatusBO adminUserStatusBO);


    /**
     * 通过用户ID查询没有权限的菜单
     *
     * @param userId
     * @return 结果信息
     * @date 2020/8/20 15:25
     **/
    @PostMapping(value = "/adminRole/queryNoAuthMenu")
    Result<List<String>> queryNoAuthMenu(@RequestParam("userId") Long userId);

    @PostMapping(value = "/adminUser/updateAdminUserLoginTime")
    Result updateAdminUserLoginTime(@RequestParam("username") String username);

    @PostMapping(value = "/adminUser/getLastedLoginUser")
    Result<Map<String, Object>> getLastedLoginUser(@RequestParam("username") String username);

    /**
     * 通过配置类型查询企业安全设置
     *
     * @param configType 1.登录设置 2.密码设置 3.安全设置
     * @return 结果信息
     */
    @PostMapping(value = "/adminCompanySecuritySetting/queryByCompanyIdType/{configType}")
    public Result<JSONObject> queryByCompanyIdType(@PathVariable("configType") Integer configType);
}
